PREVIEW: This is an example of the game you will make today!

  • Click Run to start the game. Use the left and right arrow keys to aim the hedgehog, and use the space bar to blast off. Collect as many stars as you can in 60 seconds!
  • After you play the game, click Submit and Next to build it yourself.

Click Submit and Next after every activity in this lesson to move to the next activity.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("moon") sprite = codesters.Sprite("hedgehog", 0, -210) points = 0 score_board = codesters.Display(points, -209, -209) time = 60 timer_board = codesters.Display(time, 194,-197) def interval(): global time time -=1 timer_board.update(time) if time %2 == 0: x = random.randint(-230,230) y = random.randint(0,230) star = codesters.Star(x, y, 5, 20, "yellow") if time == 0: stage.remove_all_events() text = codesters.Text("HEDGEY SCORED "+ str(points) + " POINTS!", -21, -176, "red") stage.event_interval(interval, 1) def left(): rotation = sprite.get_rotation() sprite.set_rotation(rotation+3) stage.event_key("left", left) def right(): rotation = sprite.get_rotation() sprite.set_rotation(rotation-3) stage.event_key("right", right) def release_key(): sprite.say("BLAST OFF !", 1, "white") sprite.move_forward(575) stage.wait(0.1) sprite.go_to(0, -210) stage.event_key_release("space", release_key) def collision(star, hit_sprite): global points points += 1 stage.remove_sprite(hit_sprite) score_board.update(points) sprite.event_collision(collision)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)